package com.rjpacket.supernews.app.models;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;

/**
 * Created by Administrator on 2015/3/14 0014.
 */
public class Search {


    private List<List<String>> list;

    public Search() {
        list = new LinkedList<List<String>>();
    }

    public void parseJSON(JSONObject jsonObject) {

        if (jsonObject != null) {
            try {
                JSONArray jsonArray = jsonObject.getJSONArray("hotWords");
                Search search = null;
                for (int i = 0; i < jsonArray.length(); i++) {
                    search = new Search();
                    JSONArray array = jsonArray.getJSONArray(i);
                    List<String> subList = new LinkedList<String>();
                    if (array.length() == 1) {
                        String txt = array.getString(0);
                        subList.add(txt);
                    } else {
                        String txt1 = array.getString(0);
                        subList.add(txt1);

                        String txt2 = array.getString(1);
                        subList.add(txt2);


                    }
                    list.add(subList);

                }

            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

    }

    public List<List<String>> getList() {
        return list;
    }
}
